﻿using GameEntitySystem;
using TemplatesDatabase;
using Game;
namespace Mekiasm
{
    public class ComponentBoom : Component,IUpdateable
    {
        private ComponentCreatureModel CreatureModel;

        public UpdateOrder UpdateOrder => UpdateOrder.Locomotion;
        public SubsystemExplosions Explosions;

        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            base.Load(valuesDictionary, idToEntityMap);
            CreatureModel = Entity.FindComponent<ComponentCreatureModel>();
            Explosions = Project.FindSubsystem<SubsystemExplosions>();
        }

        public void Update(float dt)
        {
            if (CreatureModel.IsAttackHitMoment)
            {
                Engine.Point3 point = Terrain.ToCell(CreatureModel.m_componentCreature.ComponentBody.Position);
                Explosions.AddExplosion(point.X,point.Y,point.Z,10f,true,false);
            }
        }
    }
}
